﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DcsGauges.Gui.Gauges.ValueConverters
{
    class TriLeverStateValueConverter : StateConverter<TriLeverGauge.LeverState>
    {
        #region Constructors
        
        public TriLeverStateValueConverter() 
            : base(convertFunction: (v) =>
                        {
                            if      (v < -0.3) return           TriLeverGauge.LeverState.State0;
                            else if (v >  0.3) return           TriLeverGauge.LeverState.State2;
                            else return                         TriLeverGauge.LeverState.State1;
            
                        },
                    convertBackFunction: (s) => 
                        {
                            if      (s == TriLeverGauge.LeverState.State0)  return -1.0f;
                            else if (s == TriLeverGauge.LeverState.State1)  return  0.0f;
                            else                                            return  1.0f;
                        })
        {

        }

        #endregion
    }
}
